<?php

class Default_Model_TableColumn_TinTuc {
	const DATE_FORMAT_FULL_EN = 'Y-m-d H:i:s';
	const DATE_FORMAT_FULL_VN = 'd/m/Y H:i:s';
	const DATE_FORMAT_SHORT_VN = 'd-m-Y';
	protected $id;
	protected $tieu_de;
	protected $gioi_thieu;
	protected $noi_dung;
	protected $hinh_anh;
	protected $luot_xem;
	protected $nguoi_tao;
	protected $ngay_tao;
	protected $trang_thai;
	
	public function __construct(array $options = null) {
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value) {
		$method = 'set' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid content property');
		}
		$this->$method($value);
	}
	
	public function __get($name) {
		$method = 'get' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid content property');
		}
		return $this->$method();
	}
	
	public function setOptions(array $options) {
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	
	//id
	public function getId() {
		return $this->id;
	}
	
	public function setId($id) {
		$this->id = $id;
	}
	
	//tieu_de
	public function getTieu_de() {
		return $this->tieu_de;
	}
	
	public function setTieu_de($tieu_de) {
		$this->tieu_de = $tieu_de;
	}
	
	//mo_ta
	public function getGioi_thieu() {
		return $this->gioi_thieu;
	}
	
	public function setGioi_thieu($gioi_thieu) {
		$this->gioi_thieu = $gioi_thieu;
	}
	
	//noi_dung
	public function getNoi_dung() {
		return $this->noi_dung;
	}
	
	public function setNoi_dung($noi_dung) {
		$this->noi_dung = $noi_dung;
	}
	
	//hinh_anh
	public function getHinh_anh() {
		return $this->hinh_anh;
	}
	
	public function setHinh_anh($hinh_anh) {
		$this->hinh_anh = $hinh_anh;
	}
	
	//luot_xem
	public function getLuot_xem() {
		return $this->luot_xem;
	}
	
	public function setLuot_xem($luot_xem) {
		$this->luot_xem = $luot_xem;
	}
	
	//nguoi_tao
	public function getNguoi_tao() {
		return $this->nguoi_tao;
	}
	
	public function setNguoi_tao($nguoi_tao) {
		$this->nguoi_tao = $nguoi_tao;
	}
	
	//ngay_tao
	public function getNgay_tao($format = self::DATE_FORMAT_FULL_VN) {
		return date($format,strtotime($this->ngay_tao));
	}
	
	public function setNgay_tao($value) {
		$this->ngay_tao = date(self::DATE_FORMAT_FULL_EN, strtotime($value));
	}
	
	//trang_thai
	public function getTrang_thai() {
		return $this->trang_thai;
	}
	
	public function setTrang_thai($trang_thai) {
		$this->trang_thai = $trang_thai;
	}
}